package cn.scw.project.goods.controller;

import cn.scw.common.constant.SysConsts;
import cn.scw.framework.web.controller.BaseController;
import cn.scw.framework.web.domain.AjaxResult;
import cn.scw.framework.web.page.TableDataInfo;
import cn.scw.project.goods.domain.GArea;
import cn.scw.project.goods.service.IGAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 地区信息Controller
 *
 * @author api
 * @date 2020-05-20
 */
@Api(tags = "地区信息")
@RestController
@RequestMapping(SysConsts.CONTEXT_PATH+"/goods/area")
public class GAreaController extends BaseController {
    @Autowired
    private IGAreaService gAreaService;

    @ApiOperation("查询地区信息列表")
    //@PreAuthorize("@ss.hasPermi('goods:area:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String code) {
        startPage();
        List<GArea> list = gAreaService.selectGAreaList(code);
        return getDataTable(list);
    }

    @ApiOperation("获取地区信息详细信息")
    //@PreAuthorize("@ss.hasPermi('goods:area:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(gAreaService.selectGAreaById(id));
    }

    @ApiOperation("获取地区信息详细信息")
    //@PreAuthorize("@ss.hasPermi('goods:area:query')")
    @GetMapping(value = "/code/{code}")
    public AjaxResult getInfo(@PathVariable String code) {
        return AjaxResult.success(gAreaService.selectGAreaByCode(code));
    }
}
